﻿using System;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MathematicallySafe.HeadCounter.Common;

namespace MathematicallySafe.HeadCounter.Views
{
    /// <summary>
    /// Interaction logic for CommandContainer.xaml
    /// </summary>
    public partial class CommandContainer : UserControl, IDisposable
    {
        public CommandContainer()
        {
            InitializeComponent();

            SimpleContainer.Instance.ContentActivated += ContentActivated;
            SimpleContainer.Instance.ContentDeactivated += ContentDeactivated;
        }

        void ContentActivated(object sender, ContentActivatedEventArgs e)
        {
            Panel.Children.Clear();
            Panel.Children.Add(e.ActivatedContent.Content);
        }

        void ContentDeactivated(object sender, EventArgs e)
        {
            Panel.Children.Clear();
        }

        public void Dispose()
        {
            SimpleContainer.Instance.ContentActivated -= ContentActivated;
            SimpleContainer.Instance.ContentDeactivated -= ContentDeactivated;
        }
    }
}
